//
//  XYVideosListController.m
//  XYSfxyxuSwift
//
//  Created by 许洋 on 2018/4/19.
//  Copyright © 2018年 许洋. All rights reserved.
//

#import "XYVideosListController.h"
#import <ZFDownload/ZFDownloadManager.h>
#import "XYDownloadController.h"

@interface XYVideosListController ()

@end

@implementation XYVideosListController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.dataSource = @[ @"http://120.25.226.186:32812/resources/videos/minion_01.mp4",
                         @"http://120.25.226.186:32812/resources/videos/minion_02.mp4",
                         @"http://120.25.226.186:32812/resources/videos/minion_03.mp4",
                         @"http://120.25.226.186:32812/resources/videos/minion_04.mp4",
                         @"http://120.25.226.186:32812/resources/videos/minion_05.mp4",
                         @"http://120.25.226.186:32812/resources/videos/minion_06.mp4",
                         @"http://120.25.226.186:32812/resources/videos/minion_07.mp4",
                         @"http://120.25.226.186:32812/resources/videos/minion_08.mp4",
                         @"http://static.smartisanos.cn/common/video/proud-farmer.mp4"];
    [self.tableView reloadData];
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"下载管理" style:UIBarButtonItemStyleDone target:self action:@selector(rightItmeAction)];

}
- (void)rightItmeAction{
    XYDownloadController *vc = [[XYDownloadController alloc]init];
    vc.title = @"下载管理";
    [self.navigationController pushViewController:vc animated:YES];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    if (!cell) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
    }
    NSString *name = [self.dataSource[indexPath.row] lastPathComponent];
    cell.textLabel.text = name;
    return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    NSString *url = self.dataSource[indexPath.row];
     [[ZFDownloadManager sharedDownloadManager] downFileUrl:url filename:[url lastPathComponent] fileimage:nil];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
